import { getUploadUrl } from "@/api/content"
const state = {
    uploadUrl: '',
    isScroll: false,
}

const mutations = {
    SET_UPLOAD_URL: (state, url) => {
        state.uploadUrl = url
    },
    SET_ISSCROLL: (state, isScroll) => {
      state.isScroll = isScroll
    },  
}

const actions = {
    // 更新上传url地址
    updateUploadUrl({ commit }) {
        return new Promise((resolve, reject) => {
            getUploadUrl().then(res => {
                commit('SET_UPLOAD_URL',res.data.uploadUrl)
                if (res.code) resolve(res.data)
                else reject('error')
            })
        })
    }
}

export default {
    namespaced: true, //命名空间
    state,
    mutations,
    actions,
}
